from rest_framework import serializers
from .models import Cart
from django.contrib.auth.models import User


# 用户信息序列化器
class UserSerializer(serializers.ModelSerializer):

    class Meta:
        model = User
        fields = ('id', 'username', 'first_name', 'last_name', 'email')


class CartSerializer(serializers.ModelSerializer):
    user = UserSerializer(many=True)

    class Meta:
        model = Cart
        fields = '__all__'